<?php

defined('IN_TS') or die('Access Denied.');
/* 
 * 配置选项
 */
switch($ts) {
	
	//基本配置
	case '':
		$arrOptions = $db->fetch_all_assoc("SELECT * FROM ".dbprefix."tbshare_options");
		$strOption  = array();
		foreach($arrOptions as $option) {
			$strOption[$option['optionname']] = $option['optionvalue'];
		}
		include template('admin/options');
		break;
	case 'do':
		$arrData = array(
			'appname' => trim($_POST['appname']),
			'appdesc' => trim($_POST['appdesc']),
			'iscreate' => trim($_POST['iscreate']),
			'isaudit' => trim($_POST['isaudit'])
		);
		foreach($arrData as $key => $val) {
			if($val != '') {
				$db->query("UPDATE ".dbprefix."tbshare_options SET optionvalue='$val' WHERE optionname='$key'");
			}
		}
		//更新缓存

		$arrOptions = $db->fetch_all_assoc("SELECT * FROM ".dbprefix."tbshare_options");
		$arrOption = array();
		foreach($arrOptions as $option) {
			$arrOption[$option['optionname']] = $option['optionvalue'];
		}
		fileWrite('tbshare_options.php','data',$arrOption);
		qiMsg("淘宝客配置修改成功！");
		break;
}